(function() {

/**
 * MyTypeField a field to create fields. The user can create any value he wants by switching fields.
 * @extends inputEx.TypeField
 * @constructor
 * @param {Object} options  Standard inputEx inputParams definition
 * by Igor Lazarev
 */

WireIt.WebUITypeField = function(options) {
	   WireIt.WebUITypeField.superclass.constructor.call(this, options);

}

YAHOO.extend(WireIt.WebUITypeField, inputEx.TypeField,{
	
	  renderComponent: function() {
      // DIV element to wrap the Field "default value"
      this.fieldValueWrapper = inputEx.cn('div', {className: "inputEx-TypeField-FieldValueWrapper"});
      this.fieldContainer.appendChild( this.fieldValueWrapper );
      
      // Render the popup that will contain the property form
      this.propertyPanel = inputEx.cn('div', {className: "inputEx-TypeField-PropertiesPanel"}, {display: 'none'});
      
      // The list of all inputEx declared types to be used in the "type" selector
      var selectOptions = [];
            selectOptions.push("string");
			selectOptions.push("text");
			selectOptions.push("integer");
			selectOptions.push("number");
			selectOptions.push("url");
			selectOptions.push("boolean");
			selectOptions.push("file");
			selectOptions.push("array");

      this.typeSelect = new inputEx.SelectField({label: "Type", selectOptions: selectOptions, selectValues: selectOptions, parentEl: this.propertyPanel});
		this.typeSelect.hide();	
	
      
      
	  
	  // DIV element to wrap the options group
	  this.groupOptionsWrapper = inputEx.cn('div');
    	  
	  this.propertyPanel.appendChild( this.groupOptionsWrapper );
	  
      // Button to switch the panel
      this.button = inputEx.cn('div', {className: "inputEx-TypeField-EditButton"});
      this.button.appendChild(this.propertyPanel);
      this.fieldContainer.appendChild(this.button);
      this.constantCheckBox = new inputEx.CheckBox({label:"Constant?",value:"false", className:"constantCheckBox", parentEl: this.propertyPanel});
	  
      // Build the groupOptions
      this.rebuildGroupOptions();
   },
   
   
		
});

if(inputEx.FileField) {
	inputEx.FileField.groupOptions = inputEx.FileField.superclass.constructor.groupOptions;
}

if(inputEx.ArrayField) {
	inputEx.ArrayField.groupOptions = inputEx.ArrayField.superclass.constructor.groupOptions;
}

inputEx.registerType("myType", WireIt.WebUITypeField);
})();
